<?php

// $Id$

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/_sys/tcms_admin_page_w_fctrl_ua.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/ci/tcms_ci_type_attr_dbc.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/ci/tcms_ci_type_dbc.class.php');


abstract class CI_Type_Edit_WP extends TCMS_Admin_Page_W_FCtrl_UA {
	protected function init_transit_vars() {
		$this->add_transit_var('vpage');
		$this->add_transit_var('category');
	}


	protected function on_add_new() {
		$current_user = $this->get_user();
		$this->form_ctrl->set_permanent_external_param('user_id', $current_user->get_id());

		$this->form_ctrl->set_permanent_external_param('add_new', 1);
		$this->export('add_new', 1);

		$context = $this->get__context();
		if ($context->exists_in_get('vpt_ci')) {
			$this->form_ctrl->set_permanent_external_param('vpt_ci', $context->get_from_get('vpt_ci'));
		}

		$vpage_id = $this->get_transit_var('vpage');
		if ($vpage_id) {
			$this->export('vpage_id', $vpage_id);
			$this->form_ctrl->set_permanent_external_param('vpage', $vpage_id);
			$this->form_ctrl->set_permanent_external_param('user_id', $this->get_user()->get_id());
		}
	}


	protected function on_received_id($object_id) {
		$current_user = $this->get_user();
		$this->form_ctrl->set_permanent_external_param('user_id', $current_user->get_id());
		$this->export('ci_id', $object_id);
	}


	protected function create_default_redir_view() {
		$object = $this->form_ctrl->get_object();
		$redir_view = $this->create_redirect_view($this->get_redir_on_success(), array('manage' => $object->get_id()));

		return $redir_view;
	}

}